import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
let router = new Router({
  mode: 'history',
  routes: [
    {
      path: '/404',
      component: (resolve) => require(['@/views/error/404'], resolve),
      hidden: true
    },
    {
      path: '/',
      name: '官网',
      component: () => import('@/views/index')
    },
    {
      path: '/message',
      name: '留言',
      component: () => import('@/views/message/index')
    },
    {
      path: '/login',
      name: '登录',
      component: () => import('@/views/login/index')
    },
    {
      path: '/reg',
      name: '登录',
      component: () => import('@/views/reg/index')
    },
    {
      path: '*', // 此处需特别注意置于最底部
      redirect: '/404'
    }
  ]
})

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
